package com.eagledata.project.business.goodsInfo.service;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.eagledata.common.utils.StringUtil;
import com.eagledata.project.business.goodsInfo.mapper.GoodsInfoMapper;
import com.eagledata.project.business.goodsInfo.domain.GoodsInfo;
import com.eagledata.project.business.goodsInfo.service.IGoodsInfoService;

/**
 * 商品 服务层实现
 * 
 * @author eagledata
 * @date 2018-06-28
 */
@Service
public class GoodsInfoServiceImpl implements IGoodsInfoService 
{
	@Autowired
	private GoodsInfoMapper goodsInfoMapper;
	
	/**
     * 查询商品信息
     * 
     * @param id 商品ID
     * @return 商品信息
     */
	 @Override
	public GoodsInfo selectGoodsInfoById(Integer id) {
	    return goodsInfoMapper.selectGoodsInfoById(id);
	}
	
	/**
     * 查询商品列表
     * 
     * @param goodsInfo 商品信息
     * @return 商品集合
     */
	 @Override
	public List<GoodsInfo> selectGoodsInfoList(GoodsInfo goodsInfo) {
	    return goodsInfoMapper.selectGoodsInfoList(goodsInfo);
	}
	
    /**
     * 新增商品
     * 
     * @param goodsInfo 商品信息
     * @return 结果
     */
	 @Override
	public int insertGoodsInfo(GoodsInfo goodsInfo) {
	    return goodsInfoMapper.insertGoodsInfo(goodsInfo);
	}
	
	/**
     * 修改商品
     * 
     * @param goodsInfo 商品信息
     * @return 结果
     */
	 @Override
	public int updateGoodsInfo(GoodsInfo goodsInfo) {
	    return goodsInfoMapper.updateGoodsInfo(goodsInfo);
	}
	
	/**
     * 保存商品
     * 
     * @param goodsInfo 商品信息
     * @return 结果
     */
	 @Override
	public int saveGoodsInfo(GoodsInfo goodsInfo) {
	    Integer id = goodsInfo.getId();
		int rows = 0;
		if (StringUtil.isNotNull(id)) {
		    rows = goodsInfoMapper.updateGoodsInfo(goodsInfo);
		} else {
		    rows = goodsInfoMapper.insertGoodsInfo(goodsInfo);
		}
		return rows;
	}
	
	/**
     * 删除商品信息
     * 
     * @param id 商品ID
     * @return 结果
     */
	 @Override
	public int deleteGoodsInfoById(Integer id) {
	    return goodsInfoMapper.deleteGoodsInfoById(id);
	}
	
	/**
     * 批量删除商品对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	 @Override
	public int batchDeleteGoodsInfo(Integer[] ids) {
		return goodsInfoMapper.batchDeleteGoodsInfo(ids);
	}
	
}
